package com.esteel.settlement.dao.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.util.StringUtils;

import com.esteel.settlement.dao.ISettFundRepository;
import com.esteel.settlement.vo.FundQueryVo;
import com.esteel.settlement.vo.TbSettFundVo;

/**
 * 复杂查询账户资金信息特定的处理实现类
 * 
 * @author zhangxiuzhi
 *
 */
public class SettFundRepositoryImpl implements ISettFundRepository {
	

	@Autowired
	private PageQuery pageQuery;
	
	@Override
	public Page<TbSettFundVo> findAll(FundQueryVo vo) {
		
		StringBuilder sb = new StringBuilder("select b.cust_name,a.* from tb_sett_fund a ,tb_sett_account b where a.cust_acct_id=b.cust_acct_id");
	
		if (!StringUtils.isEmpty(vo.getThirdCustId())){
			sb.append(" and a.third_cust_id like '%"+vo.getThirdCustId()+"%'");
		}
		if (!StringUtils.isEmpty(vo.getCustName())){
			sb.append(" and b.cust_name like '%"+vo.getCustName()+"%'");
		}
		sb.append(" order by a.tran_date desc");
		
		return pageQuery.query(sb.toString(), vo, TbSettFundVo.class);
	}

}
